<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="com.gph.saviorframework.common.model.User" %>
<%@ page import="org.apache.shiro.SecurityUtils" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="com.gph.saviorframework.security.service.MenuService" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<ul class="nav nav-list" id="steptwo">
	<%
		MenuService menuService = WebApplicationContextUtils.
				getWebApplicationContext(getServletConfig().getServletContext()).getBean(MenuService.class);

		List<Map<String,Object>> menus = menuService.findByParent("TREE_ROOT_NODE",
				((User) SecurityUtils.getSubject().getPrincipal()).getUsername());

		for(Map map : menus){
	%>
	<li class="">
		<a href="" class="dropdown-toggle">
			<i class="<%=map.get("iconCls")%>"></i>
			<span class="menu-text"><%=map.get("text")%></span>
			<b class="arrow fa fa-angle-down"></b>
		</a>
		<%
			//二级菜单
			List<Map<String,Object>> subMenus = menuService.findByParent(map.get("id").toString(),
					((User) SecurityUtils.getSubject().getPrincipal()).getUsername());
		%>
			<%if(subMenus.size()>0){%>
				<ul class="submenu">
					<%
						for(Map sub : subMenus){
							//三级菜单
							List<Map<String,Object>> thridMenus = menuService.findByParent(sub.get("id").toString(),
									((User) SecurityUtils.getSubject().getPrincipal()).getUsername());
					%>
					<%if(thridMenus.size()>0){%>
						<li class="">
							<a href="" class="dropdown-toggle">
								<i class="<%=sub.get("iconCls")%>"></i>
								<%=sub.get("text")%>
								<b class="arrow fa fa-angle-down"></b>
							</a>
							<ul class="submenu">
								<%for(Map thirdMenu : thridMenus){%>
									<li>
										<a data-url="<%=thirdMenu.get("link")%>" href="${ctx}/admin#<%=thirdMenu.get("link")%>" class="menueachlist">
											<i class=""></i>
											<%=thirdMenu.get("text")%>
										</a>
										<b class="arrow"></b>
									</li>
								<%}%>
							</ul>
						</li>
					<%}else{%>
						<li>
							<a data-url="<%=sub.get("link")%>" href="${ctx}/admin#<%=sub.get("link")%>" class="menueachlist">
								<i class=""></i>
								<%=sub.get("text")%>
							</a>
							<b class="arrow"></b>
						</li>
					<%}%>

					<%}%>
				</ul>
			<%}%>
		<%
			}
		%>
	</li>
</ul><!-- /.nav-list -->